import useActionControl from '@/hooks/useActionControl';
import SystemDictDataSelect from '@/pages/system/dictData/references/SystemDictDataSelect';
import ApiMonitorLogininfor from '@/services/monitor/ApiMonitorLogininfor';
import { ProTable } from '@ant-design/pro-components';

const SystemLogLogininforIndex = () => {
  const actionControl = useActionControl({});

  return (
    <div>
      <ProTable
        {...actionControl.table}
        request={async (params) => {
          const data = await ApiMonitorLogininfor.list(params);
          return {
            data: data.rows,
            success: true,
            total: data.total,
          };
        }}
        rowKey={'infoId'}
        columns={[
          { title: '访问编号', dataIndex: 'infoId' },
          { title: '用户名称', dataIndex: 'userName' },
          { title: '地址', dataIndex: 'ipaddr' },
          { title: '登录地点', dataIndex: 'loginLocation' },
          { title: '操作系统', dataIndex: 'os' },
          { title: '浏览器', dataIndex: 'browser' },
          {
            title: '登录状态',
            dataIndex: 'status',
            renderText: (_, record) => (
              <SystemDictDataSelect
                typeCode={'sys_common_status'}
                value={record.status}
                valueInLabel={false}
                readonly
              />
            ),
            renderFormItem: () => (
              <SystemDictDataSelect
                typeCode={'sys_common_status'}
                valueInLabel={false}
              />
            ),
          },
          { title: '描述', dataIndex: 'msg', ellipsis: true },
          {
            title: '访问时间',
            dataIndex: 'loginTime',
            valueType: 'dateTime',
            hideInSearch: true,
          },
          {
            title: '访问时间',
            dataIndex: 'loginTime',
            valueType: 'dateRange',
            hideInTable: true,
          },
        ]}
      />
    </div>
  );
};

export default SystemLogLogininforIndex;
